﻿#Region " Imports "

Imports BlazeApps.Library.News
Imports System.Data

#End Region

Partial Class Usercontrols_News_NewsArchive
	Inherits UserControlBase

#Region " Enums, Memebers and Properties "

	Private Enum NewsView
		List = 0
		View = 1
	End Enum

	Protected Property NewsGuid() As Guid
		Get
			Return GetGuidFromVS("NewsGuid")
		End Get
		Set(ByVal value As Guid)
			ViewState.Add("NewsGuid", value)
		End Set
	End Property

	Public Property sortCriteria() As String
		Get
			Return CStr(ViewState("sortCriteria"))
		End Get

		Set(ByVal Value As String)
			ViewState("sortCriteria") = Value
		End Set
	End Property

	Public Property sortDir() As String
		Get
			Return CStr(ViewState("sortDir"))
		End Get

		Set(ByVal Value As String)
			ViewState("sortDir") = Value
		End Set
	End Property

#End Region

#Region " Page Events "

	Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

		If Me.Page.IsPostBack = False Then

			'Set Default Sort Order and Direction
			Me.sortCriteria = "createdate"
			Me.sortDir = "desc"

			LoadNewsArchiveList()

		End If

	End Sub

#End Region

#Region " Save Data "

#End Region

#Region " Load Data "

	Private Sub LoadNewsArchiveList()
		Dim List As New NewsList
		Dim DT As New DataTable
		Dim DV As New DataView

		DV.Table = List.GetNewsArchive()

		DV.Sort = Me.sortCriteria & " " & Me.sortDir

		With Me.uxNewsArchiveRepeater
			.DataSource = DV
			.DataBind()
		End With

		'SetMultiViewIndex(NewsView.List)

	End Sub

#End Region

#Region " Form Controls Events "

	Protected Sub uxNewsArchiveRepeater_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.RepeaterItemEventArgs) Handles uxNewsArchiveRepeater.ItemDataBound
		If e.Item.ItemType = ListItemType.Item Or e.Item.ItemType = ListItemType.AlternatingItem Then
			Dim CPE As AjaxControlToolkit.CollapsiblePanelExtender = e.Item.FindControl("uxNewsArchiveCollapsiblePanelExtender")

			CPE.CollapsedImage = String.Format("~/App_Themes/{0}/images/icons/collapse.gif", Page.Theme.ToString.Trim)
			CPE.ExpandedImage = String.Format("~/App_Themes/{0}/images/icons/expand.gif", Page.Theme.ToString.Trim)

		End If
	End Sub

#End Region

#Region " Helpers and Methods "

#End Region

End Class
